package com.xplay.xpocker.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xplay.xpocker.config.ResultFul;
import com.xplay.xpocker.config.security.CurrentUser;
import com.xplay.xpocker.entity.GameHiMahjongAction;
import com.xplay.xpocker.entity.GameHiRoom;
import com.xplay.xpocker.entity.GameHiRoomDTO;
import com.xplay.xpocker.service.GameHiRoomService;
import com.xplay.xpocker.service.gaming.GameRuRoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "recode/history", produces = "application/json;charset=UTF-8")
public class RecodeHistoryController {
    @Autowired
    private GameHiRoomService hiRoomService;

    @GetMapping(value = "page")
    public ResultFul<Page<GameHiRoomDTO>> recodeHistory(Page<GameHiRoomDTO> page) {
        BigDecimal userId = CurrentUser.getUserId();
        Page<GameHiRoomDTO> dtoPage = hiRoomService.queryUserHistory(page, userId);
        log.info("返回了用户:{},战绩数据", userId);
        return ResultFul.ok(dtoPage);
    }

    @GetMapping(value = "list")
    public ResultFul<List<GameHiRoomDTO>> recodeHistoryList(BigDecimal roomId) {
        List<GameHiRoomDTO> dtos = hiRoomService.queryUserHistoryRoomItemList(roomId);
        return ResultFul.ok(dtos);
    }

    @GetMapping(value = "info")
    public ResultFul<List<GameHiMahjongAction>> recodeHistoryInfo(BigDecimal roomId, Integer severalInning) {
        return ResultFul.ok(hiRoomService.recodeHistoryInfo(roomId, severalInning));
    }
}
